﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true"
    CodeFile="ThietLapVayTienMat.aspx.cs" Inherits="ThietLapVayTienMat" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <div class="panel panel-success margin">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        Quản lý vay tiền mặt</h3>
                </div>
                <div class="panel-body">
                    <table width="100%">
                        <tr>
                            <td width="20%">
                                Ngày tháng<br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txtngaythang">
                                </asp:TextBox>
                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender2" runat="server"
                                    TargetControlID="txtngaythang" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtngaythang" ValidChars="/" />
                            </td>
                            <td width="20%">
                                Họ tên người cho vay<br />
                                <asp:DropDownList runat="server" CssClass="form-control " ID="drnguoichovay" DataTextField="tenncc"
                                    DataValueField="IDs">
                                </asp:DropDownList>
                            </td>
                            <td width="20%">
                                Bên vay<br />
                                <asp:DropDownList runat="server" CssClass="form-control " ID="drbenvay" DataTextField="hoten"
                                    DataValueField="IDs">
                                </asp:DropDownList>
                            </td>
                            <td width="20%">
                                Đơn vị<br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txtdonvi">
                                </asp:TextBox>
                            </td>
                            <td width="20%">
                                Số tiền<br />
                                <asp:TextBox ID="txtsotien" CssClass="form-control " runat="server"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtsotien" ValidChars=",." />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="5">
                                <asp:GridView ID="GV1" Visible="true" AutoGenerateColumns="false" runat="server"
                                    BackColor="White" Font-Size="14px" Width="98%" BorderColor="#CCCCCC" EmptyDataText="Không có dữ liệu nào"
                                    BorderStyle="None" BorderWidth="1px" CellPadding="3" EnableModelValidation="True"
                                    OnRowDeleting="gv_RowDeleting">
                                    <Columns>
                                        <asp:BoundField DataField="RowNumber" HeaderText="STT" HeaderStyle-Width="50px" HeaderStyle-HorizontalAlign="Center"
                                            ItemStyle-HorizontalAlign="Center"></asp:BoundField>
                                        <asp:TemplateField HeaderText="% Lãi" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtphantramlai" runat="server" Width="98%"></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Từ ngày" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:TextBox runat="server" CssClass="form-control " ID="tungay">
                                                </asp:TextBox>
                                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender1" runat="server"
                                                    TargetControlID="tungay" Format="dd/MM/yyyy">
                                                </cc1:CalendarExtender>
                                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" FilterType="Custom,Numbers"
                                                    TargetControlID="tungay" ValidChars="/" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Đến ngày" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:TextBox runat="server" CssClass="form-control " ID="denngay">
                                                </asp:TextBox>
                                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender3" runat="server"
                                                    TargetControlID="denngay" Format="dd/MM/yyyy">
                                                </cc1:CalendarExtender>
                                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender4" runat="server" FilterType="Custom,Numbers"
                                                    TargetControlID="denngay" ValidChars="/" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:CommandField HeaderText="Xóa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="45px"
                                            ShowDeleteButton="True" DeleteText="Xóa" />
                                    </Columns>
                                    <FooterStyle BackColor="#6EA1C0" ForeColor="#000066" />
                                    <HeaderStyle BackColor="#6EA1C0" Font-Bold="True" ForeColor="White" Height="40px"
                                        HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                                    <RowStyle ForeColor="#000066" Height="30px" />
                                    <SelectedRowStyle BackColor="#F1F1F1" Font-Bold="True" />
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding: 10px">
                                <asp:Button ID="btnAdd" ValidationGroup="add" runat="server" Text="Thêm nội dung"
                                    CssClass="btn btn-info" OnClick="btnAdd_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6">
                                <asp:Button ID="btnSave" ValidationGroup="Them" runat="server" Style="margin-left: 5px;"
                                    Text="Lưu lại" CssClass="btn btn-primary" OnClick="btnSave_Click" />
                                <asp:Button ID="btncapnhat" runat="server" Text="Cập nhật" CssClass="btn btn-info"
                                    Visible="false" OnClick="btncapnhat_Click" />
                                <asp:Button ID="btnCancel" runat="server" Text="Nhập mới" CssClass="btn btn-warning"
                                    OnClick="btnCancel_Click" />
                                <asp:Button ID="btnTraTienLai" runat="server" Text="Trả tiền lãi" CssClass="btn btn-info"
                                    Visible="false" />
                                <asp:Button ID="btnTraTienGoc" Visible="false" runat="server" Style="margin-left: 5px;"
                                    Text="Trả tiền gốc" CssClass="btn btn-primary" />
                            </td>
                        </tr>
                    </table>
                    <asp:ValidationSummary ID="ValidationSummary1" HeaderText="Bạn phải nhập các trường sau:"
                        ShowMessageBox="true" ValidationGroup="Them" ShowSummary="false" EnableClientScript="true"
                        runat="server" />
                </div>
            </div>
            <div style="margin: 5px;">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        Danh sách vay tiền mặt</div>
                    <div style="margin-bottom: 5px;">
                    </div>
                    <div style="width: 100%; margin-top: 10px; overflow: auto;" class="wrapper">
                        <div style="width: 100%; max-height: 300px;">
                            <asp:GridView ID="GV" runat="server" AutoGenerateColumns="false" BackColor="White"
                                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" EmptyDataText="Không có dữ liệu nào"
                                EnableModelValidation="True" ShowFooter="false" CssClass="form-control withall"
                                Width="99%" OnRowCommand="GV_RowCommand" onprerender="GV_PreRender">
                                <Columns>
                                    <asp:TemplateField HeaderText="Xóa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                        ItemStyle-Width="50px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="lbXoa" runat="server" Width="20px" Height="20px" ImageUrl="~/img/delete-24.png"
                                                OnClientClick="return confirm('Bạn chắc chắn muốn xóa ?')" CommandArgument='<%#Eval("IDs")%>'
                                                Text="Xóa" CommandName="Del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Sửa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                        ItemStyle-Width="50px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="lbSua" runat="server" Width="15px" Height="15px" ImageUrl="~/img/edit.ico"
                                                CommandArgument='<%#Eval("IDs")%>' Text="Sửa" CommandName="Select" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="ngaythang" ItemStyle-CssClass="padding" HeaderText="Ngày vay"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:TemplateField HeaderText="Người cho vay" ItemStyle-HorizontalAlign="Left" ItemStyle-CssClass="padding">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lbSua1" Style="color: #000066;" runat="server" Text='<%#Eval("hoten") %>'
                                                CommandArgument='<%#Eval("IDs")%>' CommandName="tralai" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="benvay" ItemStyle-CssClass="padding" HeaderText="Bên vay"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="donvi" ItemStyle-CssClass="padding" HeaderText="Đơn vị"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="sotien" ItemStyle-CssClass="padding" HeaderText="Số tiền"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="phantramlai" ItemStyle-CssClass="padding" HeaderText="Phần trăm lãi"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                                    <asp:BoundField DataField="tungay" ItemStyle-CssClass="padding" HeaderText="Từ ngày"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="denngay" ItemStyle-CssClass="padding" HeaderText="Đến ngày"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                         <asp:BoundField DataField="thanhtienlai" ItemStyle-CssClass="padding" HeaderText="Thành tiền lãi"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                         <asp:BoundField DataField="sotienconlai" ItemStyle-CssClass="padding" HeaderText="Số tiền gốc còn lại"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                </Columns>
                                <FooterStyle BackColor="White" ForeColor="#000066" Font-Bold="True" HorizontalAlign="Left" />
                                <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" Height="30px" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                <RowStyle BackColor="White" ForeColor="#000066" Height="30px" />
                                <SelectedRowStyle BackColor="Lavender" Font-Bold="false" />
                            </asp:GridView>
                        </div>
                    </div>
                </div>
                <asp:HiddenField ID="hdID" runat="server" />
                <asp:HiddenField ID="HiddenField1" runat="server" />
            </div>
            <cc1:ModalPopupExtender ID="ModalPopupExtender11" runat="server" CancelControlID="Image1"
                Drag="True" BackgroundCssClass="modalBackground" PopupControlID="Panel1" TargetControlID="btnTraTienLai"
                RepositionMode="RepositionOnWindowResize">
            </cc1:ModalPopupExtender>
            <asp:Panel ID="Panel1" runat="server" Style="display: none;">
                <table>
                    <tr>
                        <td>
                            <asp:Image ID="Image1" Width="30px" Height="25px" Style="cursor: pointer;" runat="server"
                                ImageUrl="img/close.ico" ToolTip="Đóng" />
                        </td>
                    </tr>
                </table>
                <div style="background-image: url('img/content.png'); background-repeat: repeat;
                    box-shadow: 5px 5px 5px #888; border-radius: 10px; border: 1px solid #6EA1C0;
                    margin-top: -10px;">
                    <div style="background-color: #5B5B5B; color: White; font-weight: bold; border-radius: 5px 5px 0px 0px;
                        width: 800px; text-align: center; line-height: 26px; overflow: hidden;">
                        Trả tiền lãi
                    </div>
                    <table width="800px" style="margin-top: 15px; padding: 5px;">
                        <tr>
                            <td>
                                <span style="margin-left: 5px;">Ngày tháng</span><br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txtngaytralai">
                                </asp:TextBox>
                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender1" runat="server"
                                    TargetControlID="txtngaytralai" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtngaytralai" ValidChars="/" />
                            </td>
                            <td>
                                <span style="margin-left: 5px;">Thành tiền lãi</span><br />
                                <asp:TextBox ID="txtthanhtienlai" runat="server" CssClass="form-control withall"
                                    Width="98%"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtthanhtienlai" ValidChars=",." />
                            </td>
                            <tr>
                                <td colspan="2">
                                  <asp:Button ID="btnAddTienLai" ValidationGroup="ThemCT1" CssClass="btn btn-warning"
                                        runat="server" Text="Lưu lại" onclick="btnAddTienLai_Click" />
                                        <asp:Button ID="btnSuaTienLai" ValidationGroup="ThemCT1" CssClass="btn btn-warning" Visible="false"
                                        runat="server" Text="Cập nhật" onclick="btnSuaTienLai_Click"  />
                                         <asp:Button ID="Button1" ValidationGroup="ThemCT1" CssClass="btn btn-warning" Visible="true"
                                        runat="server" Text="Nhập mới" onclick="btnCancel_Click1"  />
                                </td>
                            </tr>
                            <tr>
                            <td colspan="2">
                            <div style="width: 100%; margin-top: 10px; overflow: auto;" class="wrapper">
                        <div style="width: 100%; max-height: 300px;">
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" BackColor="White"
                                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="1" EmptyDataText="Không có dữ liệu nào"
                                EnableModelValidation="True" ShowFooter="false" CssClass="form-control withall"
                                Width="99%" onrowcommand="GridView1_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="Xóa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                        ItemStyle-Width="50px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="lbXoa" runat="server" Width="20px" Height="20px" ImageUrl="~/img/delete-24.png"
                                                OnClientClick="return confirm('Bạn chắc chắn muốn xóa ?')" CommandArgument='<%#Eval("IDs")%>'
                                                Text="Xóa" CommandName="Del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Sửa" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"
                                        ItemStyle-Width="50px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="lbSua" runat="server" Width="15px" Height="15px" ImageUrl="~/img/edit.ico"
                                                CommandArgument='<%#Eval("IDs")%>' Text="Sửa" CommandName="Select" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    
                                    <asp:BoundField DataField="ngaythang" ItemStyle-CssClass="padding" HeaderText="Ngày tháng"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" />
                                    <asp:BoundField DataField="sotien" ItemStyle-CssClass="padding" HeaderText="Tiền lãi đã thanh toán"
                                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" />
                               
                                </Columns>
                                <FooterStyle BackColor="White" ForeColor="#000066" Font-Bold="True" HorizontalAlign="Left" />
                                <HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Black" Height="30px" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                <RowStyle BackColor="White" ForeColor="#000066" Height="30px" />
                                <SelectedRowStyle BackColor="Lavender" Font-Bold="false" />
                            </asp:GridView>
                        </div>
                    </div>
                            </td>
                            </tr>
                    </table>
                </div>
            </asp:Panel>

             <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="Image2"
                Drag="True" BackgroundCssClass="modalBackground" PopupControlID="Panel2" TargetControlID="btnTraTienGoc"
                RepositionMode="RepositionOnWindowResize">
            </cc1:ModalPopupExtender>
            <asp:Panel ID="Panel2" runat="server" Style="display: none;">
                <table>
                    <tr>
                        <td>
                            <asp:Image ID="Image2" Width="30px" Height="25px" Style="cursor: pointer;" runat="server"
                                ImageUrl="img/close.ico" ToolTip="Đóng" />
                        </td>
                    </tr>
                </table>
                <div style="background-image: url('img/content.png'); background-repeat: repeat;
                    box-shadow: 5px 5px 5px #888; border-radius: 10px; border: 1px solid #6EA1C0;
                    margin-top: -10px;">
                    <div style="background-color: #5B5B5B; color: White; font-weight: bold; border-radius: 5px 5px 0px 0px;
                        width: 800px; text-align: center; line-height: 26px; overflow: hidden;">
                        Trả tiền gốc
                    </div>
                    <table width="800px" style="margin-top: 15px; padding: 5px;">
                        <tr>
                            <td>
                                <span style="margin-left: 5px;">Ngày tháng</span><br />
                                <asp:TextBox runat="server" CssClass="form-control " ID="txtngaytragoc">
                                </asp:TextBox>
                                <cc1:CalendarExtender PopupPosition="BottomRight" ID="CalendarExtender4" runat="server"
                                    TargetControlID="txtngaytragoc" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtngaytragoc" ValidChars="/" />
                            </td>
                            <td>
                                <span style="margin-left: 5px;">Thành tiền lãi</span><br />
                                <asp:TextBox ID="txtsotiengoc" runat="server" CssClass="form-control withall"
                                    Width="98%"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender7" runat="server" FilterType="Custom,Numbers"
                                    TargetControlID="txtsotiengoc" ValidChars=",." />
                            </td>
                            <tr>
                                <td colspan="2">
                                  <asp:Button ID="btntiengoc" ValidationGroup="ThemCT1" CssClass="btn btn-warning"
                                        runat="server" Text="Lưu lại" onclick="btntiengoc_Click"  />
                                       
                                </td>
                            </tr>
                            
                    </table>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
